#!/usr/bin/env node

const cp = require('child_process');

let son = cp.fork('./11-ipc-child.js');
let dau = cp.fork('./11-ipc-child.js');

console.log(`i am child process:{process.pid}`);

son.on('message',(data)=>{
  console.log(`i have a son${data}`);
});

dau.on('message',(data)=>{
  console.log(`i have a dau${data}`);
});

setTimeout(()=>{
  son.send('good good study');
},2000);

setTimeout(()=>{
  dau.send('day day up');
},3000);

setTimeout(()=>{
  son.kill('SIGINT');
  dau.kill('SIGINT');
},5000);
